﻿using Abp.Domain.Entities;
using System;
using System.ComponentModel.DataAnnotations;
using UAParser.FormFactor.Models;

namespace Mt.Site.Core.AccessStatistics.Entities
{
    public class AccessData : Entity<long>
    {
        #region 访客属性

        /// <summary>
        /// 访客编号
        /// </summary>
        [StringLength(40)]
        public string Acount { get; set; }

        /// <summary>
        /// 是否新访客
        /// </summary>
        public int IsNewVisitor { get; set; }

        /// <summary>
        /// 本次会话的编号
        /// </summary>
        [StringLength(40)]
        public string SessionId { get; set; }


        [StringLength(40)]
        public string ClientIp { get; set; }

        [StringLength(640)]
        public string UserAgent { get; set; }

        #endregion

        #region 页面属性
        [StringLength(300)]
        public string Title { get; set; }

        /// <summary>
        /// 受访页面
        /// </summary>
        [StringLength(300)]
        public string Url { get; set; }

        /// <summary>
        /// 来源页面
        /// </summary>
        [StringLength(500)]
        public string RefererUrl { get; set; }

        /// <summary>
        /// 是否支持Cookie
        /// </summary>
        public bool CookieEnabled { get; set; }

        /// <summary>
        /// 分辨率 ,如 ’1024×768′
        /// </summary>
        [StringLength(20)]
        public string Resolution { get; set; }
        /// <summary>
        /// 颜色深度，如 “32-bit”
        /// </summary>
        [StringLength(10)]
        public string ColorDepth { get; set; }

        /// <summary>
        /// 浏览器窗口高度
        /// </summary>
        public int WindowHeight { get; set; }

        /// <summary>
        /// 语言 zh-cn
        /// </summary>
        [StringLength(10)]
        public string CultureName { get; set; }

        #endregion

        #region UserAgent解析（浏览器，操作系统，设备）

        [StringLength(100)]
        public string BrowserFamily { get; set; }

        [StringLength(100)]
        public string Browser { get; set; }    //浏览器 + 版本


        [StringLength(100)]
        public string OSFamily { get; set; }   //操作系统

        [StringLength(100)]
        public string OS { get; set; }        //操作系统+版本（安卓）
        [StringLength(100)]
        public string Device { get; set; }    //设备商标 + 型号
        public DeviceFormFactor FormFactor { get; set; }  //Desktop,Tablet,Mobile

        #endregion

        #region IP解析 区域、城市、运营商

        [StringLength(20)]
        public string Region { get; set; } // 中国：省份，外国：国家
        [StringLength(20)]
        public string City { get; set; }   // 城市

        [StringLength(20)]
        public string ISP { get; set; }    // 运营商

        #endregion

        #region 解析 RefererUrl
        
        /// <summary>
        /// 入口页面的打开方式
        /// </summary>
        public SourceType SourceType { get; set; }

        public int IsExternalLinks { get; set; }
        /// <summary>
        /// 入口页面是否是否由搜索引擎打开
        /// </summary>
        public int IsSearchEngines { get; set; }

        [StringLength(10)]
        public string EngineName { get; set; }

        [StringLength(100)]
        public string Searchkey { get; set; }

        [StringLength(10)]
        public string EngineType { get; set; }

        #endregion

        #region 当前访问时间
        public DateTime VisitTime { get; set; }

        public int Year { get; set; }
        public int Month { get; set; }
        public int Day { get; set; }
        public int Hour { get; set; }
        public int Week { get; set; }

        [StringLength(10)]
        public string SundayFormart { get; set; }

        [StringLength(10)]
        public string DayFormart { get; set; }

        [StringLength(10)]
        public string MonthFormart { get; set; }

        #endregion

        #region 解析当前页面链接

        [StringLength(300)]
        public string RouteData { get; set; }

        [StringLength(10)]
        public string TenancyName { get; set; }

        public Guid? MenuId { get; set; }
        public Guid? Lv1MenuId { get; set; }

        #endregion

        #region 页面间关系

        /// <summary>
        /// 页面停留时长
        /// </summary>
        public int LengthOfStay { get; set; }
        public long TimeTotol { get; set; }  //本次会话的总时长
        public int PageNum { get; set; }   //本次会话浏览的页面数

        public int FrequentVisits { get; set; }   //当天的访问频次

        /// <summary>
        /// 上次访问的时间(cookie)
        /// </summary>
        public DateTime LastVisitTime { get; set; }

        public int IsFistPage { get; set; }//是否入口页面
        public int IsBounced { get; set; } //是否跳出页面
        public int IsEndPage { get; set; } //是否最后一个页面
        public bool IsSecondPage { get; set; }

        [StringLength(300)]
        public string FirstPageUrl { get; set; }
        public DateTime FirstPageVisitTime { get; set; }

        #endregion
    }
}
